

//Scheduler

void schedulerInit(){
  schedulerMode = -1;
  spotConfig.configAge=SCHEDULERMODETIME; // so we enter the scheduler
}

//test time and call mode functions
void updateScheduler(){
  
  //test to know if it is time to change the interaction mode
  if (spotConfig.timeRunning() >=  SCHEDULERMODETIME) {
    //define the spots variables accordingly to the new interaction mode
    switch(schedulerMode){
      
      case -1: // this is a test mode of the borders:
       spotConfig.killAll();
       spotConfig.drawScanningArea();
      
      SCHEDULERMODETIME = 60000;
      schedulerMode++;
      
       spotConfig.resetTimer();
      break;
      
      
      case 0: // one contour following
      // spotConfig.transitionStep();
       
       spotConfig.simpleTransitionStep();
       spotConfig.oneContourFollowing();
       
          // set schedule time:
      SCHEDULERMODETIME = 120000;//2 min to avoid long activation of green laser
      schedulerMode++;
      
      spotConfig.resetTimer();
      break;  
      
       case 1:
      // spotConfig.transitionStep();
       spotConfig.simpleTransitionStep();
       
       spotConfig.twoContourFollowing();
       
      SCHEDULERMODETIME = 180000; //3min
      schedulerMode++;
      
       spotConfig.resetTimer();
      break;
      
      case 2: 
    // spotConfig.transitionStep();
       spotConfig.simpleTransitionStep();
      
       spotConfig.oneSimpleBouncing();
       
       SCHEDULERMODETIME = 120000; //2min
       schedulerMode++;
       
       spotConfig.resetTimer();
       
       break;
       
       
      case 3: 
      // spotConfig.transitionStep();
       spotConfig.simpleTransitionStep();
       
       spotConfig.twoSimpleBouncing();
       
       SCHEDULERMODETIME = 180000; //2min
       schedulerMode++;
       spotConfig.resetTimer();
       break;
      
     case 4:
       // spotConfig.transitionStep();
       spotConfig.simpleTransitionStep();
       
       spotConfig.oneSnellLaw();
       
       schedulerMode++;
       SCHEDULERMODETIME = 180000; //2min
        spotConfig.resetTimer();
       break;

    default:
      schedulerMode = 0;
      break;
    } 
  }
}











